<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 300px;
            height: 240px;
            border: 1px solid #000;
        }
    </style>
</head>
<body>
    <div id="app">

        <!-- 这个事件只能由box自己触发，不能冒泡触发 -->
        <div class="box" @click.self="fn1">

            <button @click.stop="fn2">点我</button>

            <!-- 我既想阻止冒泡，又想阻止默认行为 -->
            <!-- 两个一起写，没有顺序之分 -->
            <a @click.stop.prevent="fn3" href="http://www.baidu.com">我是a标签</a>

            <button @click="fn2">点我2</button>
            <button @click="fn2">点我3</button>
            <button @click="fn2">点我4</button>

            <input type="text" @keyup.enter="fn4">
        </div>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            methods: {
                fn1 () {

                    alert('父盒子box被点了')
                },

                fn2 () {

                    alert('按钮被点了')
                },

                fn3 () {

                    alert('a被点了')
                },

                fn4 () {
                    alert('我弹起了')
                }
            }
        })
    </script>
</body>
</html>